Index = {
	
	init: function() {
		
	}
};
$(function() {
	App.init();
	App.canUse().then(function(accs) {
		BC_WS.init();
		BC_WS.onopen = function() {
			var cssCode = ".colorId_"+accs[0]+"{color:yellow;}";
			APPTool.loadCssCode(cssCode);
			
			BC_WS.send({
				cmd: "iam",
				player: accs[0],
				secret: md5(accs[0])
			});
			var f = function(data){
				if(data.code != 1){
					AlertView.layer.msg( data.msg);
				}else{
					if(BC.bcInstance){
						MainView.list.search({});
					}else{
						BC.onFinish.push(MainView.list.search);
					}
				}
			}
			BC_WS.addObserver("iam-resp", f);
			BC_WS.addObserver("msg", f);
		};
		MainView.init(Index);
	}).catch(function(err) {
		BC_Notify.show({
			msg: err.msg,
			mask:true,
			actions: [{
				type: 'btn',
				title: "刷新",
				func: function(index) {
					BC_Notify.close();
					history.go(0);
				}
			}]
		});
	})

});